public class Example {
    public static void main(String[] args) {
        int count = 0;
        String str1 = "hello, my name is John";
        String[] strs1 = str1.split(" ");
        for (int i = 0; i < strs1.length; i++) {
            count++;
        }
        System.out.println(count);
    }

}
